package com.live.dengdengtv.widget;

import android.app.Activity;
import android.app.Dialog;
import android.view.Display;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import com.live.dengdengtv.R;

/**
 * Created by wyf on 2016/8/9.
 */
public class CoverWidget {


    public Dialog productDialog(Activity activity, int ResStyleId, WindowManager.LayoutParams lp){

        final Dialog dialog = new Dialog(activity, ResStyleId);
        dialog.setContentView(R.layout.pic_choose);

//        WindowManager windowManager = activity.getWindowManager();
//        Display display = windowManager.getDefaultDisplay();
//        Window dlgwin = pickDialog.getWindow();
//        WindowManager.LayoutParams lp = dlgwin.getAttributes();
//        dlgwin.setGravity(Gravity.BOTTOM);
//        lp.width = (int)(display.getWidth()); //设置宽度

        dialog.getWindow().setAttributes(lp);
        return dialog;
    }


    /**
     * 图片选择对话框
     */
    private void showPhotoDialog(Activity activity, int ResStyleId) {
        final Dialog pickDialog = new Dialog(activity, ResStyleId);
        pickDialog.setContentView(R.layout.pic_choose);

        WindowManager windowManager = activity.getWindowManager();
        Display display = windowManager.getDefaultDisplay();
        Window dlgwin = pickDialog.getWindow();
        WindowManager.LayoutParams lp = dlgwin.getAttributes();
        dlgwin.setGravity(Gravity.BOTTOM);
        lp.width = (int)(display.getWidth()); //设置宽度

        pickDialog.getWindow().setAttributes(lp);

        TextView camera = (TextView) pickDialog.findViewById(R.id.chos_camera);
        TextView picLib = (TextView) pickDialog.findViewById(R.id.pic_lib);
        TextView cancel = (TextView) pickDialog.findViewById(R.id.btn_cancel);
        camera.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
//                getPicFrom(GETPIC_TAKEPICTURE);
                pickDialog.dismiss();
            }
        });

        picLib.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
//                getPicFrom(GETPIC_CHOOSEPIC);
                pickDialog.dismiss();
            }
        });
        cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                pickDialog.dismiss();
            }
        });

        pickDialog.show();
    }
}
